import os
# print(os.system('adb devices'))#执行但不收集结果
# print(os.popen('adb devices').readlines())#popen收集结果
class DosCmd:
    def excute_cmd_result(self,command):#需要结果的方法
        result_list=[]
        result=os.popen(command).readlines()
        for i in result:
            if i=='\n':
                continue
            result_list.append(i.strip('\n'))#去掉头尾掉换行符("\n")
        return result_list

    def excute_cmd(self,command):#不需要结果的方法
        os.system(command)

if __name__ == '__main__':
    doscmd=DosCmd()
    print(doscmd.excute_cmd_result('lsof -i:netxms-agent'))
    # doscmd.excute_cmd()